*************************************************************************************
*** Replication: Tepe, Markus and Ekaterina Widmer-Lytkina. 2026.                 ***
*** Populist Attitudes Among Civil Servants. A Source of Liberal Robustness?      ***
*** International Review of Administrative Sciences.                              ***
*************************************************************************************

* Cross-National Evidence: European Social Survey & CRONOS2


****************************************************************************************
*** Load data and merge CRON2W4e01 and ESS10
****************************************************************************************

* Access data via: https://www.europeansocialsurvey.org/data-portal 
* CRON2W4e01 Edition 1.0 28.03.2024
* ESS10e03_2 Edition 3.2 02.11.2023

cd "~"

** CRON2W4e01
use "~\CRON2W4e01.dta", replace
keep name edition proddate idno cntry c2weight mode w4q32 w4q33 w4q34 w4q35 w4q36 w4q37 w4q38 w4q39 w4q40 w4q41 w4q42 w4q43 w4q44 w4q45 w4q46
sort cntry idno mode
save "~\my.dta", replace

*** ESS10
use "~\ESS10.dta", replace
sort cntry idno mode
merge cntry idno using my.dta
keep if _merge==3

save data.dta, replace
erase my.dta


****************************************************************************************
*** Recode Variables
****************************************************************************************

*** Populism (recode)
recode w4q38 1=5 2=4 3=3 4=2 5=1, gen(w4q38r)

alpha w4q34 w4q35 w4q36 w4q37 w4q38r w4q39

sort cntry
by cntry: alpha w4q34 w4q35 w4q36 w4q37 w4q38r w4q39

*** Populism (Index and Factor Score)
gen pop = ((w4q34 + w4q35 + w4q36 + w4q37 + w4q38r + w4q39)/6)/5
factor w4q34 w4q35 w4q36 w4q37 w4q38r w4q39, pcf
predict pop_f

*** Public Employment
recode tporgwk 1=1 2=1 3=1 4=0 5=0 6=0, gen(pub)
label define pub_lbl 0 "Private Sector" 1 "Public Sector"
label values pub pub_lbl
tabulate cntry pub

*** Country ID
encode cntry, gen(cr)

*** Age
gen age = 2023- yrbrn

*** Country selection
keep if inlist(cr, 3, 4, 5, 7, 8)

gen cr_sort = .
replace cr_sort = 5  if cr == 3   
replace cr_sort = 2  if cr == 4   
replace cr_sort = 1  if cr == 5   
replace cr_sort = 3  if cr == 7 
replace cr_sort = 4  if cr == 8  

label define cr_sort_lbl ///
    5  "FI" ///
    2  "FR" ///
    1  "GB" ///
    3  "IT" ///
    4  "PT"
label values cr_sort cr_sort_lbl


****************************************************************************************
*** Analysis
****************************************************************************************


***************************
*** Appendix Figure C1 ****
***************************

reg pop i.pub##i.cr_sort i.gndr age lrscale eduyrs , cluster( idno )
margins pub, at(cr=(1(1)5))
mplotoffset, offset(0.25) recast(scatter) ytitle("Predictive Margins (with 95% CIs)") xtitle(" ") title(" ") legend(pos(6) cols(3))
graph save Appendix_Figure_C1.gph, replace


***************************
*** Appendix Table C3  ****
***************************

reg pop i.pub            i.gndr age lrscale eduyrs i.cr_sort , cluster( idno )
est store m1
reg pop i.pub##i.cr_sort i.gndr age lrscale eduyrs           , cluster( idno )
est store m2
esttab m1 m2 using Appendix_Table_C3.csv, r2 se brackets star(* 0.10 ** 0.05 *** 0.01) label nogaps  replace 

**************************
*** Appendix Table C2 ****
**************************

tabstat pop pub gndr age lrscale eduyrs, by(cr_sort) stat(n mean min max)
